package LeetCode;

import java.util.Arrays;
import java.util.Comparator;

public class LC_452_MinimumNumberofArrowstoBurstBalloons {

    public static void main(String[] args) {

    }

    static class Solution {
        public int findMinArrowShots(int[][] points) {
            if (points == null || points.length == 0 || points[0].length == 0) return 0;
            Arrays.sort(points, Comparator.comparingInt(a -> a[1]));
            long lastEnd = Long.MIN_VALUE;
            int minArrows = 0;
            for (int[] point : points) {
                if (lastEnd < point[0]) {
                    lastEnd = point[1];
                    minArrows++;
                }
            }
            return minArrows;
        }

    }
}